home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#27 (Dec 87)
/
fortran dialogs
/
xfilt.asm
< prev
next >
Wrap
Assembly Source File
|
1987-08-25
|
1KB
|
57 lines
XDEF xfilt
INCLUDE MacTraps.D
INCLUDE SysEqu.D
INCLUDE ToolEqu.D
INCLUDE QuickEqu.D
; Xfilt is the initialization code. It stores the address of the
; FORTRAN subroutine returned from ctlprc and returns a proc pointer
; whch can be passed to ModalDialog.
xfilt:
MOVEM.L A0-A1,-(SP) ;Save registers
MOVE.L 16(SP),A0 ;calling FORTRAN passes ptr to filter LEA service,A1 ;subroutine
MOVE.L (A0),(A1) ;which we store locally
LEA action,A0 ;glue procedure address is returned
MOVE.L 12(SP),A1 ;to FORTRAN on the stack
MOVE.L A0,(A1)
MOVEM.L (SP)+,A0-A1 ;Registers restored
RTS
; Action is the proc which gets called by ModalDialog. It massages the
; stack after FORTRAN finishes with it so that a Boolean result can be
; returned to ModalDialog.
action:
MOVEM.L A1/D0,-(SP) ;Save registers
PEA result ;Pass FORTRAN an address to store
;the BOOLEAN result
; Clone the stack
MOVE.L 24(SP),-(SP) ;Dg_ptr
MOVE.L 24(SP),-(SP) ;Event record
MOVE.L 24(SP),-(SP) ;ItemHit
MOVE.L service,A1 ;load pointer to FORTRAN routine
JSR (A1) ;and call it
MOVE.W result,24(SP) ;get function result and place on ;stack where ModalDialog expects it
MOVEM.L (SP)+,A1/D0 ;restore registers
; Fix the stack so that we can RTS
MOVE.L (SP)+,8(SP) ;move return address
ADD.L #8,SP ;fix stack pointer
RTS
; Declare some local storage (Note that this makes
; the routine non-reentrant)
service DC.L 0
result DC.W 0
end